Skip to content

TYP: check_untyped_defs pandas.core.resample #34692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2020

Conversation

simonjayhawkins
Copy link
Member

pandas\core\resample.py:969: error: Too many arguments for "init" of "object"
pandas\core\resample.py:1572: error: "DatetimeIndex" has no attribute "tzinfo"
pandas\core\resample.py:1573: error: "DatetimeIndex" has no attribute "tzinfo"
pandas\core\resample.py:1585: error: "PeriodIndex" has no attribute "asfreq"; maybe "freq"?
pandas\core\resample.py:1867: error: "PeriodIndex" has no attribute "asfreq"; maybe "freq"?
pandas\core\resample.py:1902: error: "PeriodIndex" has no attribute "asfreq"; maybe "freq"?

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Jun 10, 2020
@@ -966,7 +966,8 @@ def __init__(self, obj, *args, **kwargs):
for attr in self._attributes:
setattr(self, attr, kwargs.get(attr, getattr(parent, attr)))

super().__init__(None)
# error: Too many arguments for "__init__" of "object"
super().__init__(None) # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If reading the error message correctly can probably just delete this line instead of ignoring

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in a mixin, so mypy thinks super() is object.

in use, if the class using the mixin is say DatetimeIndexResamplerGroupby, super() is Resampler where init has the signature is def __init__(self, obj, groupby=None, axis=0, kind=None, **kwargs): and has a required parameter obj, hence the None here.

if we delete this line tests will fail.

========================================================================= short test summary info ========================================================================== 
FAILED pandas/tests/resample/test_datetime_index.py::test_resample_apply_with_additional_args - AttributeError: 'DatetimeIndexResamplerGroupby' object has no attribute 'b...
FAILED pandas/tests/resample/test_resampler_grouper.py::test_apply - AttributeError: 'DatetimeIndexResamplerGroupby' object has no attribute 'binner'
============================================== 2 failed, 1670 passed, 10 skipped, 1 xfailed, 2 warnings in 548.51s (0:09:08) ===============================================

@@ -1569,13 +1570,13 @@ def _get_time_period_bins(self, ax):
labels = binner = period_range(start=ax[0], end=ax[-1], freq=freq, name=ax.name)

end_stamps = (labels + freq).asfreq(freq, "s").to_timestamp()
if ax.tzinfo:
end_stamps = end_stamps.tz_localize(ax.tzinfo)
if ax.tz:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the question? these should be equivalent

@simonjayhawkins
Copy link
Member Author

@WillAyd anything more to do here?

@WillAyd WillAyd added this to the 1.1 milestone Jun 13, 2020
@WillAyd WillAyd merged commit aaf4b7b into pandas-dev:master Jun 13, 2020
@WillAyd
Copy link
Member

WillAyd commented Jun 13, 2020

Thanks @simonjayhawkins

@simonjayhawkins simonjayhawkins deleted the pandas.core.resample branch June 13, 2020 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants